from typing import List

"""
26. 删除有序数组中的重复项
https://leetcode.cn/problems/remove-duplicates-from-sorted-array/description/?envType=study-plan-v2&envId=top-interview-150
"""


class Solution:
    def removeDuplicates(self, nums: List[int]) -> int:
        """
        暴力解法
        """
        # i= 0
        # while i < len(nums) - 1:
        #     if nums[i] == nums[i + 1]:
        #         nums.pop(i + 1)
        #     else:
        #         i += 1
        # return len(nums)
        """
        双指针
        """

        # i, j = 0, 1
        # while j < len(nums):
        #     if nums[i] == nums[j]:
        #         j += 1
        #     else:
        #         nums[i+1] = nums[j]
        #         i+=1
        # return i+1

        nums1=[]
        for i in range(0,len(nums)-1):
            if nums[i] != nums[i+1]:
                nums1.append(nums[i])

        nums1.append(nums[-1])
        nums.clear()
        # nums=nums1[:]
        for j in range(0,len(nums1)):
            nums.append(nums1[j])

if __name__ == '__main__':
    s = Solution()
    print(s.removeDuplicates([0, 0, 1, 1, 1, 2, 2, 3, 3, 4]))
